package com.nut.lmsc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nut.lmsc.api.req.CouponWhiteQueryReq;
import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.CouponWhite;
import com.nut.lmsc.mapper.CouponWhiteMapper;
import com.nut.lmsc.service.CouponWhiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Slf4j
@Service
public class CouponWhiteServiceImpl implements CouponWhiteService {

    @Autowired
    private CouponWhiteMapper couponWhiteMapper;

    @Override
    public Result<IPage<CouponWhite>> listPage(CouponWhiteQueryReq req) {
        IPage<CouponWhite> list = couponWhiteMapper.listPage(req.newPage(), req.getMobile());
        return Result.ok(list);
    }

    @Override
    public Result<CouponWhite> getById(Integer id) {
        CouponWhite couponWhite = couponWhiteMapper.selectById(id);
        return Result.ok(couponWhite);
    }

    @Override
    public Result add(CouponWhite couponWhite) {
        couponWhiteMapper.insert(couponWhite);
        return Result.ok();
    }

    @Override
    public Result updateById(CouponWhite couponWhite) {
        couponWhiteMapper.updateById(couponWhite);
        return Result.ok();
    }

    @Override
    public Result deleteByIds(Set<Integer> ids) {
        couponWhiteMapper.deleteBatchIds(ids);
        return Result.ok();
    }
}
